package com.ten.jinxiancun.server.impl;

import com.ten.jinxiancun.entity.User;
import com.ten.jinxiancun.mapper.userMapper;
import com.ten.jinxiancun.server.userServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class userServerImpl implements userServer {
    @Autowired
    userMapper um;
    @Override
    public List<Map<String,Object>> getAlluser(Map<String,Object> map) {
        return um.getAlluser(map);
    }

    @Override
    public Integer userCount() {
        return um.userCount();
    }

    @Override
    public Integer AddUserFind(User user) {

        String name=user.getName();
        HashMap<String, Object> map=new HashMap<>();
        map.put("name", name);
        System.out.println("name========>"+name);
        List<Map<String,Object>> list=um.getUserName(map);
        System.out.println("lsit==========>"+list);
        if(list.size() == 0) {

            return um.AddUser(user);
        }else {
            System.out.println("用户名重复!!!");
            return 0;
        }



    }

    @Override
    public Integer UpdateUserFind(Map<String, Object> map) {
        return um.UpdateUser(map);
    }

    @Override
    public Integer DelectUserFind(Integer id) {
        return um.DelectUser(id);
    }
//下拉框
    @Override
    public List<Map<String, Object>> UserType(Map<String, Object> map) {
        return um.UserType(map);
    }

    @Override
    public List<Map<String, Object>> getRolesFind(Map<String, Object> map) {
        return um.getRoles(map);
    }

    @Override
    public List<Map<String, Object>> getUserRolesFind(Map<String, Object> map) {
        return um.getUserRoles(map);
    }

    @Override
    public Integer addRolesFind(Map<String, Object> map) {
        return um.addRoles(map);
    }

    @Override
    public Integer deleteRolesFind(Integer userId, Integer roleId) {
        return um.deleteRoles(userId,roleId);
    }

    @Override
    public Integer addRolesMenuFind(Map<String, Object> map) {
        return null;
    }

    @Override
    public Integer deleteRolesMenuFind(Integer menuId, Integer roleId) {
        return null;
    }


}
